package com.kaiwukj.android.ufamily.app.base.review;

import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.kaiwukj.android.mcas.mvp.IPresenter;
import com.kaiwukj.android.mcas.mvp.IView;

import javax.inject.Inject;

public abstract class BaseMvpActivity<P extends IPresenter> extends BaseActivity implements IView {

    @Inject
    protected P mPresenter;

    @SuppressWarnings("unchecked")
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        setupActivityComponent(getAppComponent());
        if (mPresenter != null) {
            mPresenter.attachView(this);
            mPresenter.onStart();
        }
        super.onCreate(savedInstanceState);

    }


    @Override
    protected void onDestroy() {
        if (mPresenter != null) {
            mPresenter.detachView();
        }
        super.onDestroy();
    }

    @Override
    public void showLoading() {
        super.showLoading("正在加载...");
    }

    @Override
    public void showLoading(String loadingMsg) {
        super.showLoading(loadingMsg);
    }

    @Override
    public void hideLoading() {
        super.hideLoading();
    }

    @Override
    public void killMyself() {
        onBackPressedSupport();
    }

    @Override
    public void showMessage(@NonNull String message) {
        super.showMessage(message);
    }

    @Override
    public void onTaskErr(int taskId) {
        hideLoading();
    }

    @Override
    public void onTaskSuccess(int taskId) {

    }
}
